// import Taro from '@tarojs/taro';
import { address } from '../../utils/api';

export default {
  namespace: 'address',
  state: {
    address: [],
    sug:{
      title:''
    }
  },

  effects: {
    * getAddress({ payload }, { call, put }) {
      const result = yield call(address, {
        ...payload
      })
      yield put({
        type: 'update',
        payload: {
          address: result
        }
      })
    },
    * setSug({ payload }, {_, put}) {
      yield put({
        type: 'updateSug',
        payload
      })
    }
  },

  reducers: {
    update(state, { payload: address }) {
      return { ...state, ...address }
    },
    updateSug(state, { payload: sug }) {
      return { ...state, ...sug }
    },
  }

}
